//
//  mimachongzhi.m
//  企业信息查询
//
//  Created by 梁中豪 on 16/4/21.
//  Copyright © 2016年 梁中豪. All rights reserved.
//

#import "mimachongzhi.h"
#import <BmobSDK/Bmob.h>

@interface mimachongzhi ()

- (IBAction)cancel:(id)sender;
@property (weak, nonatomic) IBOutlet UITextField *codemail;
- (IBAction)mailsubmit:(id)sender;
@end

@implementation mimachongzhi

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



- (IBAction)mailsubmit:(id)sender {
    if (_codemail.text.length!=0) {
        [BmobUser requestPasswordResetInBackgroundWithEmail:_codemail.text];
        UIAlertController *CZMM = [UIAlertController
                                      alertControllerWithTitle:@"已发送邮件"
                                      message:@"请登录邮箱重新设定密码"
                                      preferredStyle:UIAlertControllerStyleAlert];
        
        UIAlertAction *yesAction = [UIAlertAction actionWithTitle:@"确定"
                                                            style:UIAlertActionStyleCancel
                                                          handler:^(UIAlertAction *action){
                                                          }];
        [CZMM addAction:yesAction];
        //显示
        [self presentViewController:CZMM animated:true completion:nil];
        
    }
    else{
        UIAlertController *CZSB = [UIAlertController
                                      alertControllerWithTitle:@"错误"
                                      message:@"请重新输入邮箱地址"
                                      preferredStyle:UIAlertControllerStyleAlert];
        
        UIAlertAction *yesAction = [UIAlertAction actionWithTitle:@"确定"
                                                            style:UIAlertActionStyleCancel
                                                          handler:^(UIAlertAction *action){
                                                          }];
        [CZSB addAction:yesAction];
        //显示
        [self presentViewController:CZSB animated:true completion:nil];
    
    }
}
- (IBAction)cancel:(id)sender {
    [self dismissViewControllerAnimated:YES completion:nil];
}
-(IBAction)textFiledReturnEditing:(id)sender {
    [sender resignFirstResponder];
}

- (IBAction)backgroundTap:(id)sender {
    [_codemail resignFirstResponder];
}
@end
